package com.itzhoun.validator;

import com.itzhoun.annation.CronValidate;
import com.itzhoun.utils.CronUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author 周楠
 * @Date 2022/08/16/下午 10:58
 */
@Data
@Slf4j
public class CronValidator implements ConstraintValidator<CronValidate, Object> {

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        return CronUtils.isValid(constraintValidatorContext.toString());
    }

    @Override
    public void initialize(CronValidate constraintAnnotation) {

    }
}
